package bubbleindex;

/**
 * BubbleIndexThread provides a simple extension of Thread Class
 * to provide a simple approach at creating a new Run of The Bubble Index.
 * 
 * @author ttrott
 */
public class BubbleIndexThread extends Thread {

    private final BubbleIndex bubbleIndex;

    /**
     * Constructor for BubbleIndexThread
     * 
     * @param omega
     * @param mCoeff
     * @param tCrit
     * @param window
     * @param categoryName
     * @param selectionName 
     */
    BubbleIndexThread(final double omega, final double mCoeff, final double tCrit, final int window,
            final String categoryName, final String selectionName) {

        bubbleIndex = new BubbleIndex(omega, mCoeff, tCrit, window,
                categoryName, selectionName);
    }
        
    /**
     * run method provides the methods to Run The Bubble Index
     */
    @Override
    public void run() {
        synchronized(this) {

            if (!RunContext.Stop) bubbleIndex.runBubbleIndex();
            if (!RunContext.Stop) bubbleIndex.outputResults();  
            notify();

        } 
    }
}
